<?php
//it's a tool to write valid html quickly in php
//https://code.google.com/p/clean-html/
//Original code copyright (c) 2009 Bruno Trombi 
//under license gpl3


function a( $item='', $opt='' )
{
	return tag('A' ,$item, $opt );
}

?><?php

function body( $item='', $opt='' )
{
	return tag('bODY' ,$item, $opt );
}

?><?php

function caption( $item='' )
{
	return tag('caption' ,$item );
}

?><?php

//??? qui mi da strani problemi quando si richiama
function div( $item='', $opt='' )
{
	return tag('dIV' ,$item, $opt );
}

?><?php

function fieldset( $item='', $opt=''  )
{	
return tag('FIELDSET' , $item .legend( $opt ) ,"id='box'"  );
}

?><?php

function form( $item='', $opt='' )
{
	return tag('fORM' ,$item, $opt );
}

?><?php

function h1( $item='', $opt='' )
{
	return tag('h1' ,$item, $opt );
}

?><?php

function h2( $item='', $opt='' )
{
	return tag('h2' ,$item, $opt );
}

?><?php

function h3( $item='', $opt='' )
{
	return tag('h3' ,$item, $opt );
}

?><?php

function head( $item='', $opt='' )
{
	return tag('hEAD' ,$item, $opt );
}

?><?php

/*genera la pagina html, 
usa $title = titolo della pagina
usera $css = array dei css o in alternativa style.css
usera $javascript = array file javascript - sarebbe meglio usarne uno solo e qualche meccanismo di caching
usera $top per il top
usera $metatag per il metatag
usera $footer per il footer

<meta http-equiv="Content-Type"        content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="it">

<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
<link rel="alternate"     type="application/rss+xml" title="ZioBudda RSS" href="http://www.ziobudda.net/rss.xml" />

<meta name="author"                    content="GizMo" />
<meta name="copyright"                 content="Michel Morelli" />
<meta name="description"               content="OpenLinux, Il vero e unico portale dell'OpenSource., Trust CP2100 - Vai o non vai?!?!" />
<meta name="Generator"                 content="Joomla! - Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved." />
<meta name="keywords"                  content="Linux, guide, documenti, spiegazioni, faq, recensioni, trucchi, reti, rete, server, desktop, newbye, hardware, suse, opensuse, mandriva, slackware, ubuntu, kubuntu, debian, gentoo, fedora, redhat, azienda, aziende, migrazione, migrazioni, portale, collaborazioni, trust, cp, 2100, cp2100, linux, spca5xx, driver, installare, funzionare, v4l, webcam, DEALLOC error on spca50x_init_source," />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="robots"                    content="all" />
<meta name="robots"                    content="index, follow" />
<meta name="title"                     content="Trust CP2100 - Vai o non vai?!?!" />

<script type="text/javascript" src="/v001/inc/js/generico.js"></script>
<meta name="language" content="italian" /> 
*/



function html2( $body='', $bodyOpt='' )
{
global $top;
global $title;
global $bottom;

$metaa=array( 'author' => 'MR.shylock framework' ,'robots'=>'index, follow' );

html(
	 head( 
	 	 tag(TITLE,$title)
	 	.stylesheet('style.css') 
	    .meta($metaa)
	    ."<script type='text/javascript' src='/urs/js/default.js'></script>"
	 	)
	.body( $top .$body .$bottom , $bodyOpt )
);
}








?>
<?php

function html( $item='', $opt='' )
{
	echo tag('hTML' ,$item, $opt );
}

?><?php

function javascript( $path )
{
return "\n<script type=\"text/javascript\" src=\"${path}\"></script>";
}


?>
<?php

function legend( $item='' )
{	
	if( $item != '' )
		return tag('LEGEND' ,$item );
}

?><?php

function li( $item='', $opt='' )
{
		//if( is_array( $item ) )		 
		//else
			return tag('LI' ,$item, $opt );
}

?><?php

function meta( $meta=array() )
{
	foreach( $meta as $k => $v )
	{
		$r.= "\n<meta name=\"$k\" content=\"$v\" />";
	}	
return $r;
}


?><?php

function option( $item='', $opt='' )
{
	return tag('OPTION' ,$item, $opt );
}

?><?php

function select( $item='', $opt='' )
{
	return tag('SELECT' ,$item, $opt );
}

?><?php

//questa deve poter gestire anche gli array, !!!per adesso famola semplice
function stylesheet($stylesheet)
{
return "\n<link rel='stylesheet' type='text/css' href='$stylesheet' />";
}

?><?php

function table( $item='', $opt='' )
{
	return tag('tABLE' ,$item, $opt );
}

?><?php

//si puo migliorare la formattazione, e forse il passaggio di parametri
//se sapessimo quanti tag abbiamo aperti potremmo indentare bene
function tag($tag, $text, $opt='')
{
if ($text=='') return '';
if ($opt!='') $opt=' '.$opt;
return "
<$tag$opt>
	$text
</$tag>";
}

?><?php

function td( $item='', $opt='' )
{
	if($item=='') $item = '&nbsp;';
return tag('tD' ,$item, $opt );
}

?><?php

function th($text='',$opt='')
{
	return tag('th',$text,$opt);
}

?><?php

function title( $item='', $opt='' )
{
	return tag('tITLE' ,$item, $opt );
}

?><?php

function tr( $item='', $opt='' )
{
return tag('tR' ,$item, $opt );
}

?><?php

function ul( $item='', $opt='' )
{
	return tag('UL' ,$item, $opt );
}

?>
